package prova.DAO;


import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import prova.modelo.Aluno;
import prova.modelo.Turma;


/**
 * Session Bean implementation class CadastrarAlunoDAO
 */
@Stateless
public class CadastrarAlunoDAO implements CadastrarAlunoDAORemote {

	@PersistenceContext(unitName="EscolaEJB")
    private EntityManager em;
    /**
     * Default constructor. 
     */
    public CadastrarAlunoDAO() {
        // TODO Auto-generated constructor stub
    }
    
    @SuppressWarnings("unchecked")
    @Override
    public List<Aluno> getAlunos(){
            Query query = em.createQuery("SELECT a FROM Aluno a");
            return query.getResultList();
    }

	@Override
	public void inserirAluno(Aluno a) {

		em.persist(a);
		
	}
	public void inserirAlunoTurma(Turma t) {

		em.persist(t);
		
	}

	 @SuppressWarnings("unchecked")
     @Override
     public List<Turma> getTurma() {
             Query query = em.createQuery("SELECT t FROM turma t");
             return query.getResultList();
     }
	
	@Override
	public Aluno recuperarAluno(String cpf) {
		
		return null;
	}
	
	@Override
	public Aluno recuperarAlunoId(int id) {
		
		return null;
	}
}
